<?php

namespace app\admin\controller\scanwork;

use app\common\controller\Backend;
use think\Db;

class Qrc extends Backend
{
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\scanwork\Qrc;
    }

    public function index()
    {
        if ($this->request->isAjax()) {
            list($where, $sort, $order, $offset, $limit) = $this->buildparams();
            $list = $this->model->where($where)->order($sort, $order)->paginate($limit);
            $result = ["total" => $list->total(), "rows" => $list->items()];
            return json($result);
        }
        return $this->view->fetch();
    }

    public function del($ids = "")
    {
        if (!$this->request->isPost()) $this->error("Invalid parameters");
        $ids = $ids ?: $this->request->post("ids");
        if ($ids) {
            $this->model->destroy($ids);
            $this->success();
        } else {
            $this->error("Parameter ids can not be empty");
        }
    }
} 